package com.dangwen.proto.controller;

import com.dangwen.proto.service.MqttPublisherService;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Description
 *
 * @author DangWen
 */
@Controller
public class MqttController {

    @Autowired
    private MqttPublisherService mqttPublisherService;

    @PostMapping("/publishMessage")
    @ResponseBody
    public void publishMessage(String topic, String message) throws MqttException {
        mqttPublisherService.publishMessage(topic, message);
    }
}
